package com.zhanghu.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @Author: zhanghu
 * @Description: 歌手代理类
 * @Date: Create in 9:25 2020/1/20
 * @modified by:
 */
public class SingerProxy implements InvocationHandler {
    private Object object;

    public SingerProxy(Object object) {
        this.object = object;
    }

    public <T> T getProxy() {
        return (T)Proxy.newProxyInstance(object.getClass().getClassLoader(), object.getClass().getInterfaces(),
                this);
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("首先。。。。。");
        Object result = method.invoke(object, args);
        System.out.println("结束。。。。。");
        return result;
    }
}
